function decodeUplink(input) {
        return { 
            data: Decode(input.fPort, input.bytes, input.variables)
        };   
}
function Decode(fPort, bytes, variables) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.
	var value=(bytes[0]<<8 | bytes[1]) & 0x3FFF;
	var batV=value/1000;//Battery,units:V

	value=bytes[2]<<8 | bytes[3];
	if(bytes[2] & 0x80)
	{value |= 0xFFFF0000;}
	var temp_DS18B20=(value/10).toFixed(2);//DS18B20,temperature
   
	value=bytes[4]<<8 | bytes[5];
	var moisture=(value/10).toFixed(2);	
	
    value=bytes[6]<<8 | bytes[7];
	var temp=0;	
    if((value & 0x8000)>>15 === 0)
		temp=(value/10).toFixed(2);//temp_SOIL,temperature
	else if((value & 0x8000)>>15 === 1)
		temp=((value-0xFFFF)/10).toFixed(2);
	   
	var i_flag = bytes[8];
	var mes_type = bytes[10];
  return {
       Node_type:"LLMS01",
       Bat:batV,
       TempC_DS18B20:temp_DS18B20,
       Leaf_Moisture :moisture,
       Leaf_Temperature:temp,
	   Interrupt_flag:i_flag,
	   Message_type:mes_type
  };
}